package com.yanqu.road.server.cmd.charitable;

import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.charitable.CharitableDoOneTimeResult;
import com.yanqu.road.server.gameplayer.module.charitable.CharitableModule;
import com.yanqu.road.server.pb.CharitablePb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @Author wpj
 * @Date 2020/8/30
 */
@Cmd(code = GameProtocol.S_CHARITABLE_WORK_DO, desc = "行善")
public class CharitableWorkDoCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    CharitableDoOneTimeResult charitableDoOneTimeResult;

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        charitableDoOneTimeResult = player.getModule(CharitableModule.class).doCharitable();
    }

    @Override
    public void sendData(GamePlayer player) {
        player.sendPacket(ClientProtocol.U_CHARITABLE_WORK_DO, CharitablePb.getCharitableDoRespMsg(charitableDoOneTimeResult.getRet(),
                charitableDoOneTimeResult.getCharitableDoLogicResult(),
                charitableDoOneTimeResult.getCharitableType(),
                charitableDoOneTimeResult.getTodayCharitableTimes(),
                charitableDoOneTimeResult.getCharitableForUpgradeTimes()));
    }
}
